﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BufferedConsole
{
    class BufferedConsole:IDisposable
    {
        private static int capacity;
        private static StringBuilder buffer;

        BufferedConsole()
        {
            capacity = 50;
            buffer = new StringBuilder(50);
        }
        public void Write(string input) 
        {
            buffer.Append(input);
            
            while(buffer.Length>25)
            {
                for (int i = 0; i < 25; i++)
                {
                    Console.Write(buffer[i]);
                }
                Console.WriteLine();
                buffer.Remove(0, 25);
            }
            
        }
        ~BufferedConsole() 
        {
            Dispose(false);
        }

        public void Dispose() 
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        public void Dispose(bool disposing) 
        {
            if (disposing == true)
            {
                Console.WriteLine(buffer);
            }
            buffer = null;
        }

        static void Main(string[] args)
        {
            BufferedConsole input = new BufferedConsole();
            input.Write(new String('a',28));
            Console.ReadKey();
            input.Dispose();
        }
    }
}
